// *******************************************************************************************************
// # エリア
//   ・削除ボタンを押すと念押しのモーダル
// *******************************************************************************************************

$(function(){
	var isUnderIe6 = uaInfo.isIe && uaInfo.ieVr <= 6,
		isUnderIe7 = uaInfo.isIe && uaInfo.ieVr <= 7;


	/*******************************************************
	 *　モーダルで削除ボタン確認
	 *******************************************************/
	var modalDelete = new APMN.Modal({
		target: $('#modalDeleteContents'),
		close: $('#modalDeleteContents .modal_close'),
		ieVr: !(isUnderIe6)
		});

	var box_first_caution = $('.box_first_caution');
	var box_last_caution = $('.box_last_caution');
	var delete_true = $('.delete_true');
	var delete_false = $('.delete_false');

	//削除Index
	var delIndex = 0;
	var delCd = '';
	
	/*modalDelete実行*/
	$('.delete_btn a').on('click' , function(e){		
		e.preventDefault();
		
		//削除Indexを放置
		if($(this).attr('id') != undefined){
			//検索条件保存
			if($(this).attr('id').indexOf('spDel') == 0){
				delIndex = $(this).attr('id').replace('spDel', '');
			}
			//検索条件保存
			else if($(this).attr('id').indexOf('del') == 0){
				delCd = $(this).attr('id').replace('del', '');
			}
		}
	
		modalDelete.show();
		box_first_caution.show();
		box_last_caution.hide();
		
	});
	
	delete_true.on('click' , function(e){
		e.preventDefault();
		$(this).closest('.box_first_caution').hide();
		box_last_caution.show();			
		
	});
	delete_false.on('click' , function(e){
		e.preventDefault();
		
		//1件削除
		if($(this).attr('id') == 'lnkOne'){
			CONS.removeCondition(delIndex);
		}
		//すべて削除
		else if($(this).attr('id') == 'lnkAll'){
			CONS.removeConditionAll();
		} 
		
		//検討物件削除
		else if(delCd != '' && delCd != undefined){
			if($(this).find('a').hasClass('mod_btn_all_black')){
				KENTO.removeKentoList(delCd);
				window.location.reload(true);
			}				
		}
		
		modalDelete.hide();
					
	});


});
